using System;

namespace InterfaceExample // 命名空间
{
    // 定义一个接口
    public interface IShape
    {
        double Area(); // 接口中的方法没有实现

        void Display(); // 另一个接口方法
    }

    // 实现接口的类：矩形
    public class Rectangle : IShape
    {
        public double Width { get; set; }
        public double Height { get; set; }

        public Rectangle(double width, double height)
        {
            Width = width;
            Height = height;
        }

        // 实现接口方法
        public double Area()
        {
            return Width * Height;
        }

        public void Display()
        {
            Console.WriteLine($"Rectangle with Width: {Width} and Height: {Height}");
        }
    }

    // 实现接口的类：圆形
    public class Circle : IShape
    {
        public double Radius { get; set; }

        public Circle(double radius)
        {
            Radius = radius;
        }

        // 实现接口方法
        public double Area()
        {
            return Math.PI * Radius * Radius;
        }

        public void Display()
        {
            Console.WriteLine($"Circle with Radius: {Radius}");
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            IShape rectangle = new Rectangle(5, 10);
            IShape circle = new Circle(7);

            rectangle.Display(); // 输出: Rectangle with Width: 5 and Height: 10
            Console.WriteLine($"Rectangle Area: {rectangle.Area()}"); // 输出: Rectangle Area: 50

            circle.Display(); // 输出: Circle with Radius: 7
            Console.WriteLine($"Circle Area: {circle.Area()}"); // 输出: Circle Area: 153.93804002589985
        }
    }
}
